#include <iostream>
#include <stdio.h>
#include <string.h>
//#include <math.h>
using namespace std;

int t, m, n;
int ans, sum;
int tt[22];

void di(int pt)
{
    int i;
    if (pt>n || sum == m)
    {
        if (sum == m)  ++ans;
    }    
    else
    {
        for (i=tt[pt-1]; i<=m; ++i)
        {
            if (sum + i <= m)
            {
                sum += i;
                tt[pt] = i;
                di(pt+1);
                sum -= i;
            }    
        }    
    }    
}    
int main()
{
	cin >> t;
	while (t-->0)
	{
	    cin >> m >> n;
	    ans = 0;
	    sum = 0;
	    tt[0] = 1;
	    di(1);
	    cout << ans << endl;
	}    
    
    return 0;
}    


